﻿using UnityEngine;

//using for DllImport
using System.Runtime.InteropServices;

public class iOSManager : MonoBehaviour 
{
	static iOSManager _instance;
	public static string strLog = "WestWoodForever's Unity3D iOS Plugin Sample";
	//private AndroidJavaObject curActivity;
	[DllImport("__Internal")]
	private static extern void iOSPluginHelloWorld(string strMessage);
	[DllImport("__Internal")]
	private static extern void iOSPluginVisibleStatusbar(bool bVisible);

	public static iOSManager GetInstance()
	{
		if( _instance == null )
		{
			_instance = new GameObject("iOSManager").AddComponent<iOSManager>();
		}
		return _instance;
	}

	void Awake()
	{
		/*
			AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
			curActivity = jc.GetStatic<AndroidJavaObject>("currentActivity");
		*/
	}

	public void CalliOSFunc(string strMessage)
	{
		//curActivity.Call("AndroidFunc", strMsg);
		Debug.Log("UnityLog1");
		iOSPluginHelloWorld(strMessage);
		Debug.Log("UnityLog2");
	}

	public void CalliOS_Status_Func(bool bVisible)
	{
		Debug.Log("UnityLog_Status1");
		iOSPluginVisibleStatusbar (bVisible);
		Debug.Log("UnityLog_Status1");
	}

	public void SetLog(string _strLog)
	{
		Debug.Log("Set UnityLog");
		strLog = _strLog;
	}
	
}